package com.xian;

import com.xian.util.MyDateUtils;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.Date;
import java.util.Properties;
import java.util.Random;

/**
 * 制造温度文件，用于flink测试
 */
public class MakeTemperature {
    public static void main(String[] args) throws Exception {
        String lineSeparator = System.getProperty("line.separator"); //不同系统不同换行符   \r\n



        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("C:\\Users\\DELL\\Downloads\\Temperature.txt")));
        //BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("C:\\Users\\DELL\\Downloads\\cc-2.txt"),"utf-8"));

        Random random = new Random();
        for (int i=1; i<=100; i++) {
            StringBuilder sb = new StringBuilder(); //接受一行温度数据
            sb.append(i).append(",");

            sb.append(random.nextInt(99)+"."+random.nextInt(99)).append(",");

            long timestamp = MyDateUtils.getRandomTimestamp();
            //sb.append(timestamp).append(lineSeparator);
            sb.append(timestamp);

            System.out.println(sb);

            //写到文件中
            bw.write(sb.toString());
            bw.newLine(); //换行
        }

        bw.close(); //关闭资源
    }
}
